package com.xxgc.eow.service.impl;

import com.xxgc.eow.entity.Likesecondaycomment;
import com.xxgc.eow.mapper.LikesecondaycommentMapper;
import com.xxgc.eow.service.ILikesecondaycommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * <p>
 * 点赞二级评论表 服务实现类
 * </p>
 *
 * @author Mr.Abel
 * @since 2023-05-28
 */
@Service
public class LikesecondaycommentServiceImpl extends ServiceImpl<LikesecondaycommentMapper, Likesecondaycomment> implements ILikesecondaycommentService {

    @Resource
    private LikesecondaycommentMapper likesecondaycommentMapper;

    @Override
    public int insertLikeComment(Likesecondaycomment likesecondaycomment) {
        Date date = new Date();
        Instant instant = date.toInstant();
        ZoneId zoneId = ZoneId.systemDefault();
        LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
        likesecondaycomment.setCreateTime(localDateTime);
        return likesecondaycommentMapper.insertLikeComment(likesecondaycomment);
    }

    @Override
    public Integer getCommentLikeById(int secondaycommentId) {
        return likesecondaycommentMapper.getLikeNumByCommentId(secondaycommentId);
    }

    @Override
    public int updateCommentLike(int secondaycommentId, int likeNum) {
        return likesecondaycommentMapper.updateCommentLike(secondaycommentId,likeNum);
    }

    @Override
    public int delCommentLike(Likesecondaycomment likesecondaycomment) {
        Date date = new Date();
        Instant instant = date.toInstant();
        ZoneId zoneId = ZoneId.systemDefault();
        LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
        likesecondaycomment.setDestroyTime(localDateTime);
        return likesecondaycommentMapper.delLikeComment(likesecondaycomment);
    }

    @Override
    public Likesecondaycomment selectDataTf(Likesecondaycomment likesecondaycomment) {
        return likesecondaycommentMapper.selectDataTf(likesecondaycomment);
    }
}
